import axios from './utils/http';
//导入 less 文件
import './less/app.less';
//导入 config
import config from './config/config';

let searchInput = document.querySelector('.searchInput')
let searchBtn = document.querySelector('.searchBtn');

//发送 AJAX 请求 async ES8 语法
async function main(){
    //发送请求
    await axios.get('/api/book');
}

main();


//绑定事件 点击搜索
searchBtn.onclick = async function(){
    //获取关键字
    let keyword = searchInput.value;
    //更新关键字
    config.keyword = keyword;
    //发送请求
    await axios.get('/api/book', {
        params: {
            keyword
        }
    });
}